using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using FeedAntGame.Control;
using FeedAntGame.Bus;
using FeedAntGame.Sprite;
using FeedAntGame.Sprite.Event;
using FeedAntGame.Sprite.Combo;
using FeedAntGame.Support;
using System.Collections;


namespace FeedAntGame.Component
{
    public enum GameState { LOADING, READY, INGAME, GAMEOVER, NEXT_LEVEL, WIN}
    /// <summary>
    /// This is a game component that implements IUpdateable.
    /// </summary>
    public class PlayManager : Microsoft.Xna.Framework.DrawableGameComponent
    {
        //Const field
        Vector2 startBound = new Vector2(140, 20);
        Vector2 endBound = new Vector2(782, 590);
        // => mapInfo have size : 684 x 560
        Rectangle playRect = new Rectangle(156, 20, 684, 560);

        //BaseSprite
        SpriteBatch spriteBatch;
        SpriteFont spriteFont;
        List<BaseSprite> spriteList = new List<BaseSprite>(); // store temporary candy
        List<EventSprite> buttonList = new List<EventSprite>();
        List<CandyFeedSprite> candyFeedList = new List<CandyFeedSprite>();
        List<AnimateText> textList = new List<AnimateText>();

        internal List<AnimateText> TextList
        {
            get { return textList; }
        }
        //Background
        Texture2D background;
        //Battery
        Battery battery;

        //CandyFeedSprite
        Candy.TYPE[] candyFeedTypes = new Candy.TYPE[4]; // -1 : blank.
        Vector2[] candyFeedPos = new Vector2[4];
        CandyFeedSprite currentCandyFeed = null;
        internal Candy.TYPE[] CandyFeedTypes
        {
            get { return candyFeedTypes; }
            set
            {
                candyFeedTypes = value;
                for (int i = 0; i < candyFeedTypes.GetLength(0); i++)
                {
                    //add candyFeed to candyFeed list
                    AddOneCandyFeed(candyFeedPos[i],candyFeedTypes[i]);
                }
            }
        }        

        

        //MapCTL . MapCTL have size : 684 x 560
        MapCTL map;
        
        
        //Player 
        Player player;

        //command-line
        string command = "";

        //Game State
        public GameState gameState = GameState.LOADING;
        
        //sound
        Cue currentCue = null; // hold track is playing in main menu 

        public PlayManager(Game game)
            : base(game)
        {
            // TODO: Construct any child components here

        }

        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            // TODO: AddOneCandyFeed your initialization code here

            // candyFeed position
            {
                candyFeedPos[0].X = 20;
                candyFeedPos[0].Y = Game.Window.ClientBounds.Height/2 -90;
                candyFeedPos[1].X = 20 + 52;
                candyFeedPos[1].Y = Game.Window.ClientBounds.Height / 2 - 90;
                candyFeedPos[2].X = 20 ;
                candyFeedPos[2].Y = Game.Window.ClientBounds.Height / 2 - 40;
                candyFeedPos[3].X = 20 + 52;
                candyFeedPos[3].Y = Game.Window.ClientBounds.Height / 2 - 40;
            }

            base.Initialize();
        }

        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(Game.GraphicsDevice);
            spriteFont = Game.Content.Load<SpriteFont>(@"Fonts\Score");
            background = Game.Content.Load<Texture2D>(@"Images\playbackground");                      
            
            //
            // Menu Button
            //
            Button menuButton = new Button(Game, Button.TYPE.MENU, new Vector2(10, 550));
            EventSprite menuButtonSprite = (EventSprite)menuButton.Sprite;
            buttonList.Add(menuButtonSprite);
            menuButtonSprite.Click += new EventSprite.ClickButton(this.onMenuClick);
            menuButtonSprite.Hover += new EventSprite.HoverButton(this.onHandyShow);
            //
            // MapCTL
            //
            map = new MapCTL(Game, Game.Content.Load<Texture2D>(@"Images\map_green"), (int)(endBound.Y - startBound.Y),
                (int)(endBound.X - startBound.X), startBound);
            //
            //Player
            //
            player = new Player();
            
            //
            //Battery
            //
            battery = new Battery(Game, Battery.TYPE.NORMAL, new Vector2(25, 370));
            spriteList.Add(battery.Sprite);

            
            
            base.LoadContent();
        }

        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            // TODO: AddOneCandyFeed your update code here           

            switch (gameState)
            {
                case GameState.LOADING:
                    break;
                case GameState.READY:
                    {
                        
                        for (int i = 0; i < spriteList.Count; i++)
                        {
                            BaseSprite s = spriteList.ElementAt(i);
                            s.Update(gameTime, Game.Window.ClientBounds);
                        }
                        // Update loading textSprite
                        if (textList.Count == 0)
                        {
                            map.InsertMidText(textList, AnimateText.TYPE.READY);
                        }
                        for (int i = 0 ; i < textList.Count; i++)
                        {
                            AnimateText text = textList.ElementAt(i);
                            LoadingTextSprite textSprite = (text.Sprite as LoadingTextSprite);
                            if (textSprite.IsLive)
                                textSprite.Update(gameTime, Game.Window.ClientBounds);
                            if (text.Equals(AnimateText.TYPE.READY) && textSprite.IsLive == false)
                            {
                                textList.Remove(text);
                                textSprite.IsLive = true;
                                map.InsertMidText(textList,AnimateText.TYPE.GO);
                            }
                            if (text.Equals(AnimateText.TYPE.GO) && textSprite.IsLive == false)
                            {
                                textList.Remove(text);
                                textSprite.IsLive = true;
                                gameState = GameState.INGAME;
                            }
                           
                        }                        

                        //update button list
                        foreach (EventSprite button in buttonList)
                        {
                            button.Update(gameTime, Game.Window.ClientBounds);
                        }
                    }
                    break;
                case GameState.INGAME:
                    {

                        for (int i = 0; i < spriteList.Count; i++)
                        {
                            BaseSprite s = spriteList.ElementAt(i);
                            s.Update(gameTime, Game.Window.ClientBounds);
                            // TODO: Code here for candy temp object
                            if (s is BatterySprite)
                            {
                                (s as BatterySprite).Power = map.GetPowerRemain();
                            }
                            if (s is CandySprite)
                            {
                                //check if candy out of mapInfo range
                                if (!map.CoverPosition(s.Position))
                                {
                                    ((GameFA)Game).Cursor.State = Cursor.STATE_TYPE.C;
                                    if (Mouse.GetState().LeftButton == ButtonState.Pressed)
                                    {
                                        cancelPutCandy();
                                    }
                                }
                                else if ((s as CandySprite).IsTracking())
                                {
                                    ((GameFA)Game).Cursor.State = Cursor.STATE_TYPE.NORMAL_AND_C;
                                }
                                //check if candy intersect with stop sprite
                                for (int j = 0; j < map.ListBarrier.Count; j++)
                                {
                                    BaseSprite stopSprite = map.ListBarrier.ElementAt(j);
                                    {
                                        if (s.CreateCollisionRect(Vector2.Zero,s.Width/2,s.Height/2).Intersects(stopSprite.collisionRect))
                                        {
                                            s.Visible = false;
                                            ((GameFA)Game).Cursor.State = Cursor.STATE_TYPE.C;
                                            break;
                                        }
                                        else
                                        {
                                            s.Visible = true;
                                        }
                                    }
                                }

                                //check if "back" action (it's mean: not put candy to mapInfo)
                                if (Keyboard.GetState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Escape)
                                    || Mouse.GetState().RightButton == ButtonState.Pressed)
                                {
                                    cancelPutCandy();
                                    spriteList.Remove(s);
                                    continue;
                                }

                                bool ready = true;//ready = true if it doesn't intersect with all stop sprite

                                //check if candy is ready to put on mapInfo
                                if ((s as CandySprite).IsReadyToPutOnMap())
                                {

                                    for (int j = 0; j < map.ListBarrier.Count; j++)
                                    {
                                        BaseSprite stopSprite = map.ListBarrier.ElementAt(j);
                                        {
                                            if (s.CreateCollisionRect(Vector2.Zero, s.Width / 2, s.Height / 2).Intersects(stopSprite.collisionRect))
                                            {
                                                ready = false;
                                                break;
                                            }
                                        }
                                    }
                                    if (ready)
                                    {
                                        s.Scale /= 2;
                                        if (!player.PutCandy((s as CandySprite), map))
                                        {
                                            cancelPutCandy();
                                        }
                                        successPutCandy();
                                    }
                                    else
                                    {
                                        cancelPutCandy();
                                    }
                                    spriteList.Remove(s);
                                }
                            }

                        }

                        // Update candyFeed
                        foreach (CandyFeedSprite candy in candyFeedList)
                        {
                            candy.Update(gameTime, Game.Window.ClientBounds);
                        }

                        // Update mapInfo
                        map.Update(gameTime, Game.Window.ClientBounds);
                        //mapInfo.currentPower -= 0.1f;

                        //update button list
                        foreach (EventSprite button in buttonList)
                        {
                            button.Update(gameTime, Game.Window.ClientBounds);
                        }

                        //update textSprite
                        for (int i = 0; i < textList.Count; i++)
                        {
                            AnimateText text = textList.ElementAt(i);
                            LoadingTextSprite textSprite = (text.Sprite as LoadingTextSprite);
                            if (textSprite.IsLive)
                            {
                                textSprite.Update(gameTime, Game.Window.ClientBounds);
                            }
                            else
                            {
                                textList.Remove(text);
                            }
                        }
                        //Catch command-line
                        catchCommandLine();            
                    }
                    break;
                case GameState.NEXT_LEVEL:
                    
                    for (int i = 0; i < textList.Count; i++)
                    {
                        AnimateText text = textList.ElementAt(i);
                        LoadingTextSprite textSprite = (text.Sprite as LoadingTextSprite);
                        if (textSprite.IsLive)
                        {
                            if (!text.Equals(AnimateText.TYPE.NEXT_LEVEL) || text.Equals(AnimateText.TYPE.NEXT_LEVEL) && 
                                textSprite.delay(gameTime.ElapsedGameTime.Milliseconds))
                            {
                                textSprite.Update(gameTime, Game.Window.ClientBounds);
                            }                            
                        }

                        if (text.Equals(AnimateText.TYPE.NEXT_LEVEL) && textSprite.IsLive == false)
                        {
                            textList.Remove(text);
                            textSprite.IsLive = true;
                            if (map.GetMap(++map.currentLevel))
                            {
                                //Go to next level
                                ((GameFA)Game).OpenPickCandy();
                                this.Enabled = false;
                                ResetCandyFeed();
                                this.textList.Clear();
                                gameState = GameState.READY;
                            }
                        }
                    }
                    break;
                case GameState.GAMEOVER:
                    break;
                case GameState.WIN:
                    
                    for (int i = 0; i < textList.Count; i++)
                    {
                        AnimateText text = textList.ElementAt(i);
                        LoadingTextSprite textSprite = (text.Sprite as LoadingTextSprite);
                        if (textSprite.IsLive)
                        {
                            if (!text.Equals(AnimateText.TYPE.WIN) || text.Equals(AnimateText.TYPE.WIN) && 
                                textSprite.delay(gameTime.ElapsedGameTime.Milliseconds))
                            {
                                textSprite.Update(gameTime, Game.Window.ClientBounds);
                            }
                            if (text.Equals(AnimateText.TYPE.WIN) && !textSprite.IsLive)
                            {
                                textList.Remove(text);
                                textSprite.IsLive = true;
                                //load high score
                                bool isReady = false;
                                List<ArrayList> hs = Database.HighScore.GetAllRank();
                                foreach (ArrayList row in hs)
                                {
                                    int hsRowScore = Int32.Parse((row[3]).ToString());
                                    if (this.GetLastScore() > hsRowScore)
                                    {
                                        isReady = true;
                                        break;
                                    }
                                }
                                //check player's score is ready to put in high score
                                if (isReady)
                                {
                                    //open save score dialog
                                    ((GameFA)Game).OpenSaveScoreDlg();
                                    Database.Hien_Trang.LuuHienTrang(1, 0);
                                }
                                else
                                {
                                    //Go to main menu
                                    Database.Hien_Trang.LuuHienTrang(1, 0);
                                    ((GameFA)Game).OpenPlayAgainDlg();
                                    
                                }
                            }
                        }
                        
                    }
                    break;
            }
            //create enemy sprites
            
            
            base.Update(gameTime);
        }

        private void successPutCandy()
        {
            if (currentCandyFeed != null)
            {
                ((GameFA)Game).PlayCue("throw");
                currentCandyFeed.SuccessAction(true);
                currentCandyFeed = null;
            }

        }

        public void cancelPutCandy()
        {
            if (currentCandyFeed != null)
            {
                currentCandyFeed.SuccessAction(false);
                currentCandyFeed = null;
            }
            if (this.Enabled == false)
            {
                foreach (BaseSprite s in spriteList)
                {
                    if (s is CandySprite)
                    {
                        spriteList.Remove(s);
                    }
                }
            }
        }

       

        public override void Draw(GameTime gameTime)
        {
            // TODO: AddOneCandyFeed your draw code here
            //GraphicsDevice.Clear(MyColor.CornflowerBlue);
            string currentLevel = ((int)map.currentLevel).ToString();
            string currentScore = ((int) map.currentScore).ToString();
            spriteBatch.Begin();
            switch (gameState)
            {
                case GameState.LOADING:
                    // Draw mapInfo
                    map.Draw(gameTime, spriteBatch);

                    // Draw bg 
                    spriteBatch.Draw(background, new Rectangle(0, 0, Game.Window.ClientBounds.Width,
                        Game.Window.ClientBounds.Height), Color.White);
                    // Draw current level
                    spriteBatch.DrawString(spriteFont, currentLevel, new Vector2(66 - 7* currentLevel.Length, 50), Color.Black);
                    // Draw current score
                    spriteBatch.DrawString(spriteFont, currentScore, new Vector2(66 - 6 * currentScore.Length, 150), Color.Black);

                    // Draw button list
                    foreach (EventSprite button in buttonList)
                        button.Draw(gameTime, spriteBatch);
                    break;
                case GameState.READY:
                    {
                        // Draw mapInfo
                        map.Draw(gameTime, spriteBatch);

                        // Draw bg 
                        spriteBatch.Draw(background, new Rectangle(0, 0, Game.Window.ClientBounds.Width,
                            Game.Window.ClientBounds.Height), Color.White);
                        // Draw current level
                        spriteBatch.DrawString(spriteFont, map.currentLevel.ToString(), new Vector2(66 - 7 * currentLevel.Length, 50), Color.Black);
                        // Draw current score
                        spriteBatch.DrawString(spriteFont, currentScore, new Vector2(66 - 6 * currentScore.Length, 150), Color.Black);

                        // Draw button list
                        foreach (EventSprite button in buttonList)
                            button.Draw(gameTime, spriteBatch);

                        // Draw candyFeed list
                        foreach (CandyFeedSprite candy in candyFeedList)
                            candy.Draw(gameTime, spriteBatch);

                        // Draw sprite list
                        foreach (BaseSprite s in spriteList)
                            s.Draw(gameTime, spriteBatch);  

                        // Draw loading textSprite
                        foreach (AnimateText text in textList)
                            text.Sprite.Draw(gameTime, spriteBatch);
                    }
                    break;
                case GameState.INGAME:
                    {
                        // Draw mapInfo
                        map.Draw(gameTime, spriteBatch);

                        // Draw bg 
                        spriteBatch.Draw(background, new Rectangle(0, 0, Game.Window.ClientBounds.Width, 
                            Game.Window.ClientBounds.Height), Color.White);
                        // Draw current level
                        spriteBatch.DrawString(spriteFont, map.currentLevel.ToString(), new Vector2(66 - 7 * currentLevel.Length, 50), Color.Black);
                        // Draw current score
                        spriteBatch.DrawString(spriteFont, currentScore, new Vector2(66 - 6 * currentScore.Length, 150), Color.Black);

                        // Draw button list
                        foreach (EventSprite button in buttonList)
                            button.Draw(gameTime, spriteBatch);

                        // Draw candyFeed list
                        foreach (CandyFeedSprite candy in candyFeedList)
                            candy.Draw(gameTime, spriteBatch);

                        // Draw sprite list
                        foreach (BaseSprite s in spriteList)
                            s.Draw(gameTime, spriteBatch);

                        // Draw loading textSprite
                        foreach (AnimateText text in textList)
                            text.Sprite.Draw(gameTime, spriteBatch);
                    }
                    break;
                case GameState.NEXT_LEVEL:
                    // Draw mapInfo
                    map.Draw(gameTime, spriteBatch);

                    // Draw bg 
                    spriteBatch.Draw(background, new Rectangle(0, 0, Game.Window.ClientBounds.Width,
                        Game.Window.ClientBounds.Height), Color.White);
                    // Draw current level
                    spriteBatch.DrawString(spriteFont, map.currentLevel.ToString(), new Vector2(66 - 7 * currentLevel.Length, 50), Color.Black);
                    // Draw current score
                    spriteBatch.DrawString(spriteFont, currentScore, new Vector2(66 - 6 * currentScore.Length, 150), Color.Black);

                    // Draw button list
                    foreach (EventSprite button in buttonList)
                        button.Draw(gameTime, spriteBatch);

                    // Draw candyFeed list
                    foreach (CandyFeedSprite candy in candyFeedList)
                        candy.Draw(gameTime, spriteBatch);

                    // Draw loading textSprite
                    foreach (AnimateText text in textList)
                        text.Sprite.Draw(gameTime, spriteBatch);
                    break;
                case GameState.GAMEOVER:
                    break;
                case GameState.WIN:
                    // Draw mapInfo
                    map.Draw(gameTime, spriteBatch);

                    // Draw bg 
                    spriteBatch.Draw(background, new Rectangle(0, 0, Game.Window.ClientBounds.Width,
                        Game.Window.ClientBounds.Height), Color.White);
                    // Draw current level
                    spriteBatch.DrawString(spriteFont, map.currentLevel.ToString(), new Vector2(66 - 7 * currentLevel.Length, 50), Color.Black);
                    // Draw current score
                    spriteBatch.DrawString(spriteFont, currentScore, new Vector2(66 - 6 * currentScore.Length, 150), Color.Black);

                    // Draw button list
                    foreach (EventSprite button in buttonList)
                        button.Draw(gameTime, spriteBatch);

                    // Draw candyFeed list
                    foreach (CandyFeedSprite candy in candyFeedList)
                        candy.Draw(gameTime, spriteBatch);

                    // Draw loading textSprite
                    foreach (AnimateText text in textList)
                        text.Sprite.Draw(gameTime, spriteBatch);
                    break;
            }
                        
            spriteBatch.End();

            base.Draw(gameTime);
        }


        


        

        public Vector2 GetPlayerPosition()
        {
            return Vector2.Zero;
        }
        /************************************************************************/
        /*                          Event                                                                     */
        /************************************************************************/
        private void onHandyShow()
        {
            ((GameFA)Game).Cursor.State = Cursor.STATE_TYPE.HAND;
        }
        private void onMenuClick()
        {
            ((GameFA)Game).OpenMenuDlg();

        }

        protected override void OnVisibleChanged(object sender, EventArgs args)
        {
            
            if (this.Visible == true)
            {                
                //Get current mapInfo in save game .If it is false -> new game
                int[] saveGame = Database.Hien_Trang.LayHienTrang();
                
                if (saveGame.Count() != 0) // save game exist
                {
                    // open save game
                    this.map.currentLevel = saveGame[0];
                    this.map.currentScore= saveGame[1];
                    this.map.lastScore = saveGame[1];
                }
                else
                {
                    this.map.currentLevel = 1;
                    this.map.currentScore = 0;
                }
                this.ResetCandyFeed();
                this.textList.Clear();
                this.map.GetMap(map.currentLevel);
                ((GameFA)Game).OpenPickCandy();
                this.Enabled = false;
                //play theme song: UNDERFX
                currentCue = ((GameFA)Game).PlayCue("UNDERFX");
            }
            else
            {
                ((GameFA)Game).StopCue(currentCue, AudioStopOptions.Immediate);
            }
            base.OnVisibleChanged(sender, args);
        }

        /************************************************************************/
        /*                          Create mapInfo                                                                     */
        /************************************************************************/

        

        /************************************************************************/
        /*                      Command-Line                                                                     */
        /************************************************************************/
        private void catchCommandLine()
        {
            //new stop object
            if (Keyboard.GetState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.N))
            {
                command += 'N';
            }
            if (Keyboard.GetState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.E))
            {
                command += 'E';
            }
            if (Keyboard.GetState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.W))
            {
                command += 'W';
            }

            if (command.Contains("N"))
            {
                command = "";
                map.SpawnStopObject((GameFA)Game, Barrier.TYPE.ROCK3, 
                    new Vector2(Mouse.GetState().X-map.Position.X-30, Mouse.GetState().Y-map.Position.Y-30));

                string lines = (new Vector2(Mouse.GetState().X - map.Position.X-30, Mouse.GetState().Y - map.Position.Y-30)).ToString()+"\n";

                // Write the string to a file.
                System.IO.StreamWriter file = new System.IO.StreamWriter(@"D:\position.txt",true);                
                file.WriteLine(lines);
                file.Close();
            }
            if (command.Contains("E"))
            {
                command = "";
                map.SetBaseRoad(MapCTL.ROAD_POINT_TYPE.ORANGE,
                    new Vector2(Mouse.GetState().X - map.Position.X , Mouse.GetState().Y - map.Position.Y ));

                string lines = (new Vector2(Mouse.GetState().X - map.Position.X - 30, Mouse.GetState().Y - map.Position.Y - 30)).ToString() + "\n";

                // Write the string to a file.
                System.IO.StreamWriter file = new System.IO.StreamWriter(@"D:\position_2.txt", true);
                file.WriteLine(lines);
                file.Close();
            }

        }

        /************************************************************************/
        /*                      Other methods                                                                     */
        /************************************************************************/
        private void AddOneCandyFeed(Vector2 position, Candy.TYPE type)
        {
            CandyFeed candyFeed = new CandyFeed(Game,type,position);
            CandyFeedSprite sprite = (CandyFeedSprite)candyFeed.Sprite;
            candyFeedList.Add(sprite);
            sprite.Hover += new EventSprite.HoverButton(this.onHandyShow);
            sprite.Click += new EventSprite.ClickButton(
                    () =>
                    {
                        //candyFeed.SuccessAction(true); // be on test
                        switch (sprite.Status)
                        {
                            // TODO: code here
                            case CandyFeedSprite.STATUS.READY:
                                currentCandyFeed = sprite;
                                AddOneCandy(sprite.Position, candyFeed.Type);
                                break;
                        }
                    }); 
        }

        private void AddOneCandy(Vector2 position, Candy.TYPE type)
        {            
            Candy candy = new Candy(Game, type, position);
            BaseSprite candySprite = candy.Sprite;
            candySprite.Scale = 0.5f;
            bool exist = false; // false: sprite doesn't have candy
            foreach(BaseSprite s in spriteList)
            {
                if (s is CandySprite)
                {
                    exist = true;
                    break;
                }
            }
            if (!exist)
            {
                spriteList.Add(candy.Sprite);
            }
            
        }

        public void ResetCandyFeed()
        {
            candyFeedList.Clear();
        }

        public long GetCurrentScore()
        {
            return (long)map.currentScore;
        }
        public long GetLastScore()
        {
            return (long)map.lastScore;
        }

        public int GetCurrentLevel()
        {
            return map.currentLevel;
        }

        public void InsertCombo(int number, Vector2 position)
        {
            
            AnimateText text = null;
            switch (number)
            {
                case 1:
                    
                    break;
                case 2:
                    text = new AnimateText(Game, AnimateText.TYPE.COMBO_X2, position);
                    (text.Sprite as LoadingTextSprite).DelayTime = 1000;
                    textList.Add(text);
                    break;
                case 3:
                    text = new AnimateText(Game, AnimateText.TYPE.COMBO_X3, position);
                    (text.Sprite as LoadingTextSprite).DelayTime = 1000;
                    textList.Add(text);
                    break;
                default:
                    text = new AnimateText(Game, AnimateText.TYPE.COMBO_X4, position);
                    (text.Sprite as LoadingTextSprite).DelayTime = 1000;
                    textList.Add(text);
                    break;
            }
            
        }

        public void SetNewGame()
        {
            map.currentScore = 0;
            map.currentLevel = 1;
        }
        
    }
}
